﻿using System;
using System.Linq;
using System.Linq.Expressions;
using Webdiyer.AspNetCore;
using PlatformNetCore.Entity;
using PlatformNetCore.IRepository;

namespace PlatformNetCore.Repository
{
    public class VideosRepository : Repository<Videos>, IVideosRepository
    {
        public VideosRepository(PlatformContext dbContext) : base(dbContext)
        {

        }

        public override PagedList<Videos> GetPagedList(int pageIndex, int pageSize, Expression<Func<Videos, bool>> predicate)
        {
            return _dbContext.Videos.Where(predicate).OrderByDescending(k => k.AddDate).ToPagedList(pageIndex, pageSize);
        }

        public override PagedList<Videos> GetPagerList(int pageIndex, int pageSize, Expression<Func<Videos, bool>> predicate)
        {
            return _dbContext.Videos.Where(predicate).OrderBy(m => m.SortNo).ThenByDescending(k => k.AddDate).ToPagedList(pageIndex, pageSize);
        }

    }
}
